export function ShuffleArrayReturnNew(array: any[]) {
    let result = array.slice();
    ShuffleArray(result);
    return result;
}

export function ShuffleArray(array: any[]) {
    for (let i = array.length - 1; i > 0; i--) {
        let j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
    for (let i = array.length - 1; i > 0; i--) {
        let j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
}

export function GetRandomInt(min: number, max: number): number {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

export function sleep(time: number) {
    return new Promise(resolve => setTimeout(resolve, time));
}